//           https://www.nowcoder.com/questionTerminal/d1ac7f15d5dc40b39a7d6cb11a01407e?page=11&onlyReference=false





#include <iostream>
#include <string>
using namespace std;

bool check(string s)
{
    for (int i = 0; i < s.size(); i++)
        if ((s[i] % 2) == 0)
            return true;
    return false;
}


int main()
{
    int q;
    cin >> q;
    while (q--)
    {
        long long x;
        cin >> x;
        string s = to_string(x);
        if (!check(s))
            cout << "-1" << endl;
        else
        {
            if (s.back() % 2 == 0)
                cout << s << endl;
            else
            {
                for (int i = s.size() - 1; i >= 0; i--)
                    if (s[i] % 2 == 0)
                    {
                        swap(s[i], s[s.size() - 1]);
                        break;
                    }
                cout << s << endl;
            }
        }
    }
    return 0;
}